<?php
/**
 * Formulário de criação de novos utilizadores
 * 
 * @author Ricardo Simão
 * 
 * @version 1.1
 */

class App_Forms_Newuser extends App_Forms_TemplateAbstract implements App_Interfaces_IForms {
	
	/**
	 * Nome do utilizador
	 *
	 * @var string
	 */
	protected $username;
	
	/**
	 * Palavra passe do utilizador
	 *
	 * @var string
	 */
	protected $password;
	
	/**
	 * Email do utilizador
	 *
	 * @var string
	 */
	protected $email;
	
	/**
	 * Nome completo do utilizador
	 *
	 * @var string
	 */
	protected $name;
	
	/**
	 * Se o utilizador faz parte dos administradores
	 *
	 * @var int
	 */
	protected $admin;
	
	/**
	 * Botão de envio
	 *
	 * @var mixed
	 */
	protected $submit;
	
	
	
	
	/**
	 * Criação do formulário de novo utilizador
	 *
	 * @return Zend_Form
	 */
	public static function getForm() {
		$username = new Zend_Form_Element_Text ( 'username' );
		$username->setLabel ( 'Utilizador:' )
				 ->setRequired ( true )
				 ->setAttrib ( 'class', self::CLASS_BOX_TYPE_MEDIUM)
				 ->setErrorMessages ( array (self::ERR_EMPTY_FIELD ) );
		
		$password = new Zend_Form_Element_Password ( 'password' );
		$password->setLabel ( 'Password:' )
				 ->setRequired ( true )
				 ->setAttrib ( 'class', self::CLASS_BOX_TYPE_MEDIUM )
				 ->addValidators(array(
    								array('stringLength', false, array(4, 12)),
								 ))
				 ->setErrorMessages(array(self::ERR_LENGHT_PASSWD));
		
		$email = new Zend_Form_Element_Text ( 'email' );
		$email->setLabel ( 'Email:' )
			  ->setRequired ( true )
			  ->setAttrib ( 'class', self::CLASS_BOX_TYPE_MEDIUM )
			  ->addValidator('EmailAddress', FALSE)
			  ->setErrorMessages(array(self::ERR_EMAIL_MALFORMED));
		
		$name = new Zend_Form_Element_Text ( 'real_name' );
		$name->setLabel ( 'Nome Completo:' )
			 ->setRequired ( true )
			 ->setAttrib ( 'class', self::CLASS_BOX_TYPE_MEDIUM )
			 ->setErrorMessages ( array (self::ERR_EMPTY_FIELD) );
		
		$admin = new Zend_Form_Element_Checkbox ( 'admin' );
		$admin->setLabel ( 'Administrador:' );
		
		$submit = new Zend_Form_Element_Submit ( 'submit' );
		$submit->setLabel ( 'Criar' );
		
		$form = new Zend_Form ( );
		$form->setAction ( '/admin/newuser' )
			 ->setMethod ( 'post' )
			 ->addElement ( $username )
			 ->addElement ( $password )
			 ->addElement ( $email )
			 ->addElement ( $name )
			 ->addElement ( $admin )
			 ->addElement ( $submit );
		
		return $form;
	
	}
}

?>